<template>
	  <a-modal  :width='500'
	  title="选择付款银行"
	  :visible="visible"
	  @ok="handleOk"
	  :confirmLoading="confirmLoading"
	  @cancel="handleCancel"
	  >
	  	请选择银行账户：
			<a-select  style="width: 260px"  v-model='value'  @change='(val)=>handleChange(val)'>
		      <a-select-option v-for='(item,index)  in  data' :key='index' :value='item.code'>{{item.bankAccount}}</a-select-option> 
		    </a-select>
		<div class='mt12'>没有预选银行？请<span class='color-blue cursor' @click='write()'>手动输入</span></div>
	  </a-modal>
</template>

<script >
import  { getEntBank }  from  '@/api/customer/index'
export default {
  name: 'accountModify',
  props:{
      visible:{
        type:Boolean,
        default:true
      },
      // entCode:{
      //   type:String,
      //   default:''
      // }
  },
	data () {
		return {
			confirmLoading: false,
			data:[], 
			value:'',
			selectedBank:{},
			entCode:''
		}
	},
	methods:{
		//提交 信息
	    handleOk(e) { 
	        this.$emit('handleOk',this.selectedBank,this.entCode) 
	    },
	    handleCancel(e) {
	        this.$emit('handleCancel') 
	    },
	    write(){
	    	this.$emit('write',this.entCode)
	    },
	    handleChange(val){
	    	// console.log(val)
	    	//array
	    	this.selectedBank = this.data.filter(item=>{
	    		return item.code == val
	    	})[0]
	    }
	},
	mounted(){
		this.$nextTick(()=>{
			this.$on('openDialog',function(entCode){
				this.selectedBank={}
				this.data = []
				this.value = ''

				this.entCode = entCode
			  	getEntBank(entCode).then((res)=>{
			        if(res.data.flag == true){
			        	this.data = res.data.dataList
			        }
			    })
			})
		})
	}
}
</script>